package com.snake.mylibrary.mina;

import android.content.Context;



public class ConnectionConfig {
    private Context mContext;
    private String ip;
    private int port;
    private int readBufferSize;
    private int connectionTimeout;

    public Context getContext() {
        return mContext;
    }

    public int getReadBufferSize() {
        return readBufferSize;
    }

    public int getPort() {
        return port;
    }

    public String getIp() {
        return ip;
    }

    public int getConnectionTimeout() {
        return connectionTimeout;
    }

    public static class Builder{
        private Context mContext;
        private String ip = "192.168.1.102";
        private int port = 8888;
        private int readBufferSize = 10240;
        private int connectionTimeout = 10000;

        public Builder(Context context){
            mContext = context;
        }
        public Builder setIp(String ip){
            this.ip = ip;
            return this;
        }

        public Builder setPort(int port) {
            this.port = port;
            return this;
        }

        public Builder setReadBufferSize(int readBufferSize) {
            this.readBufferSize = readBufferSize;
            return this;
        }

        public Builder setConnectionTimeout(int connectionTimeout) {
            this.connectionTimeout = connectionTimeout;
            return this;
        }
        private void applyConfig(ConnectionConfig config){
            config.mContext = this.mContext;
            config.ip = this.ip;
            config.port = this.port;
            config.readBufferSize = this.readBufferSize;
            config.connectionTimeout = this.connectionTimeout;
        }

        public ConnectionConfig build(){
            ConnectionConfig config = new ConnectionConfig();
            applyConfig(config);
            return config;
        }
    }

}
